package com.zhuiYun.project.api.dynamicAudit.service.impl;
import com.zhuiYun.project.api.dynamicAudit.entity.DynamicAudit;
import com.zhuiYun.project.api.dynamicAudit.mapper.DynamicAuditMapper;
import com.zhuiYun.project.api.dynamicAudit.service.DynamicAuditService;
import com.zhuiYun.project.util.pageUtil.MybatisPageHelper;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import com.zhuiYun.project.util.pageUtil.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mao
 * @date 4.5 14:10
 */
@Service
public class DynamicAuditServiceImpl implements DynamicAuditService {

    @Autowired
    DynamicAuditMapper dynamicAuditMapper;

    /**
     * @Description: 待审核全查 分页 nickname模糊查
     * @param pageRequest
     * @param nickName
     * @return: com.zhuiYun.project.util.pageUtil.PageResult
     * @Author: mao
     * @Date: 2023/4/11 10:16
     */
    @Override
    public PageResult getDyamic(PageRequest pageRequest, String nickName) {
        MybatisPageHelper.startPage(pageRequest);
        List<DynamicAudit> dyamic = dynamicAuditMapper.getDyamic(pageRequest, nickName);
        return MybatisPageHelper.getPageResult(dyamic);
    }

    /**
     * @Description:修改待审核状态为1 审核通过
     * @param id
     * @return: int
     * @Author: mao
     * @Date: 2023/4/11 10:17
     */
    @Override
    public int UpdateDynamicAuditList(int id) {
        DynamicAudit dynamicAudit = new DynamicAudit();
        dynamicAudit.setId(id);
        dynamicAudit.setDynamicContentFlag(1);
        return dynamicAuditMapper.updateByPrimaryKeySelective(dynamicAudit);
    }

    /**
     * @Description: 修改待审核状态 为2 审核不通过
     * @param id
     * @return: int
     * @Author: mao
     * @Date: 2023/4/11 10:18
     */
    @Override
    public int UpdateDynamicAuditListTwo(int id) {
        DynamicAudit dynamicAudit = new DynamicAudit();
        dynamicAudit.setId(id);
        dynamicAudit.setDynamicContentFlag(2);
        return dynamicAuditMapper.updateByPrimaryKeySelective(dynamicAudit);
    }

}
